package com.vipheyue.bigbusiness.activity;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.view.WindowManager;

import com.vipheyue.bigbusiness.MainActivity;
import com.vipheyue.bigbusiness.R;
import com.vipheyue.bigbusiness.utils.DataUtil;

public class SplashActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_splash);
//        BmobUpdateAgent.initAppVersion(this);
//        if(!TextUtils.isEmpty(SharePreferencesUtil.getSpString("crashInfo","",this))){
//            CrashInfoBean crashInfoBean =new CrashInfoBean();
//            crashInfoBean.setCrashInfo(SharePreferencesUtil.getSpString("crashInfo","",this));
//            crashInfoBean.save(this, new SaveListener() {
//                @Override
//                public void onSuccess() {
//                    SharePreferencesUtil.putSpString("crashInfo","",SplashActivity.this);//置空
//                }
//
//                @Override
//                public void onFailure(int i, String s) {
//
//                }
//            });
//        }
//        CrashHandler crashHandler = CrashHandler.getInstance();
//        crashHandler.init(getApplicationContext());
//        crashHandler.upCrashInfo(this);
        startActivity();
    }

    private void startActivity() {

        new Handler().postDelayed(new Runnable() {//延迟进入主界面
            @Override
            public void run() {
                SharedPreferences sp= DataUtil.getSP(SplashActivity.this);
                boolean isFirstUse = sp.getBoolean("isFirstUse", true);
                if (isFirstUse) {
                    Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                } else {
                    Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                }
            }
        }, 3000);//启动时间
    }
}